package com.meiyue.controller;

import com.meiyue.bean.base.PageModel;
import com.meiyue.bean.entity.TestCitiesEntity;
import com.meiyue.bean.entity.TestDriverLicenseTypesEntity;
import com.meiyue.bean.protocol.NetResult;
import com.meiyue.library.utils.MsgUtils;
import com.meiyue.library.utils.ResultUtils;
import com.meiyue.locallibs.websocket.MyWsClient;
import com.meiyue.service.CityService;
import com.meiyue.service.DriverLicenseTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.socket.client.WebSocketClient;
import org.springframework.web.socket.messaging.WebSocketStompClient;

/**
 * MeiyueJavaProject
 * com.meiyue.controller
 * Created by Chris Chen
 * 2017/9/14
 * Explain:悦道 测试用
 */
@RestController
@RequestMapping("/yuedao")
public class YuedaoController {
    @Autowired
    CityService cityService;
    @Autowired
    DriverLicenseTypeService dltService;


    @RequestMapping("/add")
    public NetResult<Boolean> add(String city) {
        return ResultUtils.buildResult(cityService.addOne(new TestCitiesEntity(city)));
    }

    @RequestMapping("/addCities")
    public NetResult<Boolean> addCities(String cities) {
        return ResultUtils.buildResult(cityService.addCityList(cities));
    }

    @RequestMapping("/getCityPage")
    public NetResult<PageModel<TestCitiesEntity>> getCityPage(int page, int pageSize) {
        return ResultUtils.buildResult(cityService.getPage(page, pageSize));
    }

    @RequestMapping("/addDlt")
    public NetResult<Boolean> addDlt(String type) {
        return ResultUtils.buildResult(dltService.addOne(new TestDriverLicenseTypesEntity(type)));
    }

    @RequestMapping("/sendMsg")
    public String sendMsg(String message) {
        MsgUtils.println(message);
        return message;
    }
}
